function reduce(array, fn, total){
    const len = array.length
    for (let i = 0; i < len; i++) {
        const fItem = array[i]
        if (i === 0 && total === undefined) {
            total = fItem
            continue
        }
        total = fn(total, fItem)
    }
    return total
}

export default reduce